fix: use Vite plugin for Google Analytics (vocs v2 compat)#153
fix: use Vite plugin for Google Analytics (vocs v2 compat)#153brendanjryan merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins.
509466d to
d13373e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 509466dce3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const id = process.env.VITE_GA_MEASUREMENT_ID | ||
| return { | ||
| name: 'google-analytics', | ||
| transformIndexHtml() { |
There was a problem hiding this comment.
Inject GA in SSR head instead of index template
Using transformIndexHtml here does not add GA to normal documentation pages in this Vocs/Waku setup: route HTML is produced through the SSR renderHtml pipeline, while index.html is only used as fallback shell content. As a result, GA scripts are still absent on standard page renders (the primary traffic path), so this change does not actually fix analytics collection outside fallback responses.
Useful? React with 👍 / 👎.
Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog.
* chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com>
* chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. * fix: sql editor theme sync (#157) --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com>
* chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. * fix: sql editor theme sync (#157) --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com>
* chore: tweaks (#1) * docs: add Machine Payments (MPP) section (#2) * docs: add Machine Payments (MPP) section Add 6 new pages under guide/machine-payments: - Overview: protocol intro, payment flow diagram, intents, use cases - Client quickstart: fetch polyfill, Wagmi, per-request accounts, manual handling - Server quickstart: framework middleware, manual mode, push/pull, fee sponsorship - Accept one-time payments: charge intent guide with multi-framework examples - Accept pay-as-you-go payments: session intent with payment channel diagram - Accept streamed payments: SSE per-token billing with session vouchers Also adds MermaidDiagram component (from mpp repo) for animated sequence diagrams and sidebar entry under 'Start Building on Tempo'. * fix: use mpp.dev instead of mpp.sh for all links * fix: resolve tsgo build errors and biome warnings in MermaidDiagram * fix(ci): increase Node.js heap to 4GB for vite build OOM * docs: use stepped layout for Foundry install (#7) * docs: add Python SDK page (#4) * docs: pin tempo-alloy (#5) * docs: tempo-go v0.3.0 (#6) * docs: add Python to SDKs Support banner (#9) * docs: add cast tabs to tempo tx examples (#10) * docs: add Rust tabs to tempo tx examples (#11) * docs: pytempo examples (#12) * docs: add Go tabs to tempo tx examples (#13) * docs: add 'How sessions work' diagram to streamed payments page (#14) * docs: add more sdks to "Accept a payment" (#16) * docs: add more sdks to "Send a payment" (#15) * chore: update new code examples to mainnet (#19) * chore(python): bump pytempo v0.4.0 (#18) * fix(rust): use signer provider for sending txs (#17) * docs: testnet -> mainnet for code examples, network details, etc (#8) * chore: tweaks * docs: testnet -> mainnet for code examples, network details, etc * ci: sync workflow (#22) * chore: docs sync (#23) * ci: up (#24) * chore: sync from tempoxyz/docs (#26) * chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> * chore: bump vocs next (#27) * docs(sdks): pay fees with stablecoin examples (#20) * chore: bump vocs to 8b55a2c (#28) Amp-Thread-ID: https://ampcode.com/threads/T-019cf7ba-9f13-7756-aa25-35383710d245 * docs(sdks): fee sponsorship (#21) * feat: add interactive terminal demo to machine payments page (#30) * docs(nav): reorganize build and quickstart sections (#32) Update sidebar structure to surface Building with AI under Changelog Rename, move up Build on Tempo * docs: getting funds page, update building with ai (#35) * add getting funds page, update building with ai cards Amp-Thread-ID: https://ampcode.com/threads/T-019cf8df-2af2-75ef-96cd-c899b6d4230a Co-authored-by: Amp <amp@ampcode.com> * up --------- Co-authored-by: Amp <amp@ampcode.com> * docs: add Tempo Wallet CLI docs section (#36) Amp-Thread-ID: https://ampcode.com/threads/T-019cf986-a283-7649-8612-6b9cd5d0f478 Co-authored-by: Amp <amp@ampcode.com> * docs: add SKILL.md and AI card to homepage (#37) * Add SKILL.md and AI card to homepage Amp-Thread-ID: https://ampcode.com/threads/T-019cfa0d-e023-71d1-a478-bd2f2ce4de3f Co-authored-by: Amp <amp@ampcode.com> * Rename building-with-ai to using-tempo-with-ai and update config Amp-Thread-ID: https://ampcode.com/threads/T-019cfa0d-e023-71d1-a478-bd2f2ce4de3f Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com> * chore: sync from tempoxyz/docs (#38) * chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com> * chore: redirects (#40) * fix: redirect (#41) * chore: sync from tempoxyz/docs (#42) * chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. * fix: sql editor theme sync (#157) --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com> * chore: point index supply guide to mainnet (#39) * Mainnet ready: ecosystem infrastructure pages, connection updates (#44) * mainnet-ready: update developer tools, connection details, and explorer URLs - Add Bridges, Security & Compliance, Orchestration cards to developer tools - Add CoinGecko, Redstone to Data & Analytics - Add Elliptic, TRM Labs to Security & Compliance - Add Bridge (Stripe) to Orchestration - Restructure Wallets with Embedded and Custodial & Institutional subcategories - Add BitGo, Fireblocks to Custodial & Institutional - Add Bridges section with Relay and Squid - Update mainnet/testnet RPC and explorer URLs Amp-Thread-ID: https://ampcode.com/threads/T-019cf98b-501e-7538-8115-cd3039d8ad94 Co-authored-by: Amp <amp@ampcode.com> * add missing providers and update connection tables - Add SonarX, SQD, Zerion to Data & Analytics - Add Pimlico to Smart Contract Libraries - Add Validation Cloud to Node Infrastructure - Move Utila to Custodial & Institutional - Add Across, Bungee to Bridges - Update Tempo Explorer with mainnet/testnet URLs - Make connect-to-wallets tables consistent with connection-details Amp-Thread-ID: https://ampcode.com/threads/T-019cf98b-501e-7538-8115-cd3039d8ad94 Co-authored-by: Amp <amp@ampcode.com> * split Developer Tools into Tempo Ecosystem Infrastructure section - Create /ecosystem/ with individual pages for each category: Bridges, Data & Analytics, Block Explorers, Wallets, Smart Contract Libraries, Node Infrastructure, Security & Compliance, Orchestration - Add collapsible 'Tempo Ecosystem Infrastructure' sidebar section - Add redirect from /quickstart/developer-tools to /ecosystem - Add new providers: Across, Bungee, CoinGecko, Redstone, SonarX, SQD, Zerion, Elliptic, TRM Labs, BitGo, Fireblocks, Pimlico, Validation Cloud, Bridge (Stripe) - Restructure Wallets into Embedded + Custodial & Institutional - Update mainnet/testnet RPC and explorer URLs - Make connection tables consistent across pages Amp-Thread-ID: https://ampcode.com/threads/T-019cf98b-501e-7538-8115-cd3039d8ad94 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Uddhav <255779543+letstokenize@users.noreply.github.com> Co-authored-by: Amp <amp@ampcode.com> * Restructure CLI docs under Tempo Developer Tools (#43) Merge 'Tempo Wallet CLI' and 'Tempo SDKs' sidebar sections into 'Tempo Developer Tools' with CLI and SDKs subsections. CLI section now has four pages: - Overview: what the binary does, install, agent setup with tabbed code group (Claude Code / Amp / Codex) - tempo wallet: auth, keys, funds, service discovery, sessions - tempo request: curl-like MPP client with automatic payment - tempo node: node flags grouped by function, plus tempo download Other changes: - Move URL from /wallet to /cli with 301 redirects - Delete troubleshooting page (redundant) - Add CLI cross-links in Using Tempo with AI, Getting Funds, Machine Payments, and Node Installation pages - Upgrade agent setup prompts to tabbed code groups site-wide Amp-Thread-ID: https://ampcode.com/threads/T-019cfda6-a311-765e-8012-69eeeb9129e2 Co-authored-by: Amp <amp@ampcode.com> * chore: sync from tempoxyz/docs (#47) * chore: remove thirdweb from developer tools page (#146) Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> * fix(docs): add fee recipient language (#147) * feat: add Google Analytics (gtag.js) via static HTML head (#150) * fix(node): prep for mainnet (#144) * fix: revert vocs.config.tsx to .ts to fix Vercel SSR (#151) The Vocs SSR bundle hardcodes an import to dist/server/vocs.config.js. When the source file is .tsx, Vite outputs it differently, causing ERR_MODULE_NOT_FOUND and 500 errors on every page. - Rename vocs.config.tsx back to vocs.config.ts - Replace JSX with React.createElement calls for gtag head config - Update biome.json override to match new filename * fix: load env vars into process.env for vocs.config.ts (#152) Use Vite's loadEnv() to populate process.env with VITE_* env vars before the vocs() plugin initializes. Without this, VITE_GA_MEASUREMENT_ID is not available when vocs.config.ts is evaluated, causing the Google Analytics gtag to be silently skipped. This matches the pattern used in the mpp site's vite.config.ts. * fix: use Vite plugin for Google Analytics (vocs v2 compat) (#153) * fix: use transformIndexHtml for GA instead of vocs.config head Vocs v2 removed the `head` config property — it existed in v1 but is silently ignored in v2. Move Google Analytics injection to a Vite plugin using transformIndexHtml, which correctly injects script tags into the HTML during build. Also keep the loadEnv fix so VITE_* env vars from .env files are available to all plugins. * fix: use React component for GA instead of dead transformIndexHtml Vocs v2 uses Waku (RSC) which bypasses Vite's HTML pipeline entirely. transformIndexHtml is never invoked. Use a client-side React component in _layout.tsx instead, matching the pattern used for Vercel Analytics and PostHog. * fix: sql editor theme sync (#157) --------- Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com> * chore: biome format Amp-Thread-ID: https://ampcode.com/threads/T-019cfdd1-6acc-74a0-b7b6-e79bb18273e8 --------- Co-authored-by: Brendan Ryan <brendanjryan@users.noreply.github.com> Co-authored-by: onbjerg <onbjerg@users.noreply.github.com> Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> Co-authored-by: Derek Cofausper <256792747+decofe@users.noreply.github.com> Co-authored-by: joshitzko <82132285+joshitzko@users.noreply.github.com> Co-authored-by: zhygis <5236121+Zygimantass@users.noreply.github.com> Co-authored-by: Uddhav <uddhav@centennial.capital> Co-authored-by: jxom <7336481+jxom@users.noreply.github.com> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Kartik <slokhx@gmail.com> Co-authored-by: Uddhav <255779543+letstokenize@users.noreply.github.com> Co-authored-by: Liam Horne <liam@lihorne.com>
Problem
Google Analytics gtag.js was not appearing on docs.tempo.xyz despite
VITE_GA_MEASUREMENT_IDbeing correctly set in Vercel env vars.This stems from using a
headconfig which is not available in vocv2